package com.cci.kangdao.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.cci.kangdao.service.EngineTypeService;
import com.cci.kangdao.utilTool.ParameterTool;

//机型controller
@Controller
public class EngineTypeController {
    private Logger log = Logger.getLogger(this.getClass().getName());
    @Autowired
    private EngineTypeService engineTypeService;

    //获取机型信息
    @RequestMapping("/getEngineTypeList.aspx")
    public ModelAndView getEngineMsg(HttpServletRequest request,
                                     HttpServletResponse response) throws Exception {
        try {
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            map.put("request", request);
            return engineTypeService.getEngineTypeList(map);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            ParameterTool.writeErrorResponse(response);
        }
        return null;
    }


    //npbu添加或修改机型后同步到e路康明斯系统
    @RequestMapping("/syncNpbuEngineTypeToEApp.aspx")
    public ModelAndView syncNpbuEngineTypeToEApp(@RequestBody String paramStr, HttpServletRequest request,
                                                 HttpServletResponse response) throws Exception {
        try {
            return engineTypeService.syncNpbuEngineTypeToEApp(paramStr,request,response);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            ParameterTool.writeErrorResponse(response);
        }
        return null;
    }
}
